import sys

# decorators (must be first)
def eg(f=None,lst=[]): 
  if f: 
    lst.append(f)
    return f
  else:
    for one in lst: 
      print '\n--|',one.func_name,'|','-'*40,'\n';one()

def test(f=None,lst=[]): 
  if f: 
    lst.append(f)
    return f
  else: 
    passes=fails=0
    for one in lst: 
      want,got = one()
      if want == got:
        passes += 1; print "PASSED:",one.func_name
      else:
        fails += 1;  print "FAILED:",one.func_name
    if lst:
      print 'ok=',passes,'bad=',fails,\
            'passed=', round(10000*passes/(passes+fails))/100,'%'

def egs(cxt,globs,args=sys.argv):
  if cxt == "__main__": 
    eval(args[1] +'()',globs) if len(args)==2 else eg()

def tests(cxt,globs,args=sys.argv):
  if cxt == "__main__": 
    eval(args[1] +'()') if len(args)==2 else demo()
